/* 
 * File:   SceneParser.h
 * Author: brady
 *
 * Created on March 25, 2011, 6:18 PM
 */

#ifndef SCENEPARSER_H
#define	SCENEPARSER_H

#include <iostream>
#include <fstream>
#include <sstream>
#include <handleArgs.h>
#include <PNGImage.h>
#include <Vector3D.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/stat.h>
#include "Scene.h"
#include "Sphere.h"
#include "Triangle.h"
#include "Shader.h"
#include "LambertianShader.h"
#include "BlinnPhongShader.h"
#include "Mesh.h"
#include "DielectricShader.h"
#include "Instance.h"
#include "Construct.h"
#include "CheckerboardTexture.h"
#include "ColoredTexture.h"
#include "PerlinTexture.h"
#include "WoodTexture.h"

using namespace std;

class SceneParser {
public:
    SceneParser();
    SceneParser(string inputFile);
    SceneParser(const SceneParser& orig);
    Scene& Parse();
    virtual ~SceneParser();
private:
    Shader* BuildShader();
    Shape* BuildShape();
    Light* BuildLight();
    Camera* BuildCamera();
    void RenderBoundingBox(Shape* s);
    Shape* BuildSphere();
    Shape* BuildBox();
    Shape* BuildMesh();
    Shape* BuildInstance();
    Shape* BuildTriangle();
    Shape* BuildConstruct();
    Texture* BuildTexture();



    Shape* GetInstanceShape(string instanceId);
    fstream in_file;
    string inputFile;
    string bite;
    vector<Shape*> InstanceShapes;
    Scene scene;
    bool ValidShader(string shader){return (shader == "lambertian" || shader == "blinnphong" || shader == "dielectric");}
    bool ValidOption(string opt){return (opt == "shape" || opt == "light" || opt == "camera" || opt == "scene" || opt == "instance" || in_file.eof());}
    bool ValidShape(string shape){return (shape == "sphere" || shape == "triangle" || shape == "mesh" || shape == "box");}

};

#endif	/* SCENEPARSER_H */

